<?
require_once("../config/dbconn.php");require_once("../config/usercls.php");

if($act=='msgdo'){
	$msg='';
	if(trim($glyid)=='') $msg.="请选择管理员\\n";
	if(trim($title)=='') $msg.="请输入留言标题\\n";
	if(trim($content)=='') $msg.="请输入内容\\n";
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	
	//插入数据库
	$dataArray['username']=$_SESSION['sys_username'];
	$dataArray['glyid']=$glyid;
	$dataArray['title']=$title;
	$dataArray['content']=addslashes($content);
	$dataArray['addtime']=$curtime;
	
	$db->insert("{$db_prefix}msgs",$dataArray);
	echo "<script>alert('留言成功');location.href='msg_lst.php';</script>";exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
			 
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" ></td>
    <td width="100%" height="29" valign="top"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">&nbsp;&nbsp;会员留言</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" ></td>
  </tr>
  <tr>
    <td height="71" valign="middle" >&nbsp;</td>
    <td valign="top" ><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top">
		<form action="?act=msgdo" method="post" name="form1" id="form1">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="3"></td>
            </tr>
            <tr>
              <td height="30" colspan="3">
			  
			  <table width="100%" height="240" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="30" align="center" bgcolor="#f2f2f2" class="left_txt">管理员</td>
                  <td height="30" bgcolor="#f2f2f2" class="left_txt"><label>
                  <select name="glyid" id="glyid">
				  <option value="">请选择管理员</option>
				  <?
				  $sqlgly="select * from {$db_prefix}admin888 where 1";
				  $resultgly=$db->query($sqlgly);
				  while($rsgly=$db->fetch_array($resultgly)){
				  	//部门
					$sqlbm="select * from {$db_prefix}departs where id='".$rsgly['departid']."'";
					$rsbm=$db->get_one($sqlbm);
				  	echo "<option value='{$rsgly['id']}'>{$rsbm['flname']} - {$rsgly['nickname']}</option>";
				  }
				  $db->free_result($resultgly);
				  ?>
                  </select>
                  </label></td>
                </tr>
                <tr>
                  <td height="30" align="center"  bgcolor="#f2f2f2" class="left_txt">标题</td>
                  <td height="30" class="left_txt"  bgcolor="#f2f2f2"><input name="title" type="text" id="title" value="<?=$rs1['title']?>" size="50" /></td>
                  </tr>
				   <tr>
				     <td height="30" align="center" bgcolor="#f2f2f2" class="left_txt">留言内容</td>
				     <td height="30" bgcolor="#f2f2f2" class="left_txt">&nbsp;</td>
				     </tr>
				   <tr>
                  <td height="30" colspan="2" align="center" bgcolor="#f2f2f2" class="left_txt">
				  <script charset="utf-8" src="../kindeditor/kindeditor-min.js"></script>
			<script charset="utf-8" src="../kindeditor/lang/zh_CN.js"></script>
					<script>
					KindEditor.ready(function(K) {
						K.create('#content', {
							themeType : 'simple'
						});
					});
				</script>
				<textarea id="content" name="content" style="width:100%;height:200px;visibility:hidden;"><?=stripslashes($rs1['content'])?></textarea>
				  </td>
                  </tr>
              </table></td>
            </tr>
            
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
            <tr>
              <td width="50%" height="30" align="right"><input type="submit" value="发送留言" name="B1" /></td>
              <td width="6%" height="30" align="right">&nbsp;</td>
              <td width="44%" height="30"><input type="reset" value="取消设置" name="B12" /></td>
            </tr>
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
          </table>
		  </form>
		  </td>
      </tr>
    </table></td>
    <td >&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" ></td>
      <td height="17" valign="top" ></td>
    <td ></td>
  </tr>
</table>

</body>
</html>